package cn.stylefeng.guns.modular.business.frequency.appversion.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.business.frequency.appversion.model.param.AppVersionParam;
import cn.stylefeng.guns.modular.business.frequency.appversion.service.AppVersionService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 版本表 控制器
 *
 * @author: 李文龙
 * @date: 2022/01/13 14:17
 */
@RestController
public class AppVersionController {

    @Resource
    private AppVersionService appVersionService;

    /**
     * 分页查询版本表
     *
     * @author 李文龙
     * @date 2022/01/13 14:17
     */
    @PostMapping("/appVersion/page")
    @BusinessLog(title = "版本表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(AppVersionParam appVersionParam) {
        return new SuccessResponseData(appVersionService.page(appVersionParam));
    }


    /**
     * 查看详情版本表
     *
     * @author 李文龙
     * @date 2022/01/13 14:17
     */
    @PostMapping("/appVersion/detail")
    @BusinessLog(title = "版本表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@RequestBody AppVersionParam appVersionParam) {
        return new SuccessResponseData(appVersionService.detail(appVersionParam));
    }

    /**
     * 新增接口
     *
     * @author 刘耀
     * @Date 2021-02-22
     */
    @RequestMapping("/appVersion/addItem")
    @ResponseBody
    public ResponseData addItem(@RequestBody AppVersionParam appVersionParam) {
        return this.appVersionService.add(appVersionParam);
    }


    /**
     * 删除版本表
     *
     * @author 李文龙
     * @date 2022/01/13 14:17
     */
    @PostMapping("/appVersion/delete")
    @BusinessLog(title = "版本表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(AppVersionParam.delete.class) AppVersionParam appVersionParam) {
        appVersionService.delete(appVersionParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑版本表
     *
     * @author 李文龙
     * @date 2022/01/13 14:17
     */
    @PostMapping("/appVersion/edit")
    @BusinessLog(title = "版本表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(AppVersionParam.edit.class) AppVersionParam appVersionParam) {
        return appVersionService.edit(appVersionParam);
    }


}
